home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
016a
/
xtclock2.zip
/
SETCLOCK.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-07-30
|
2KB
|
84 lines
/* Program SETCLOCK */
/* Version 2.0 */
/* Compiler MIX Power C */
/* Author Gerald M. Vrooman */
/* Date 12/21/89 */
/* SETCLOCK can be used to initialize most XT clock cards. */
/* The Multi I/O card that this routine was designed for */
/* uses the following ports: */
/* &h242 - Second */
/* &h243 - Minute */
/* &h244 - Hour */
/* &h246 - Day */
/* &h247 - Month */
/* &h249 - Year */
/* SETCLOCK can be easily modified for clock cards using */
/* different ports by changing the arguments used with */
/* outportb(). */
#include <stdio.h>
#include <dos.h>
main()
{
int year,month,day,hour,minute,second;
char buffer[20];
printf("\nSETCLOCK Written 1991 by Gerald M. Vrooman\n\n");
/* read in date and time from console */
printf("enter last two digits of year (yy): ");
gets(buffer);
year = atoi(buffer);
printf("enter month (mm): ");
gets(buffer);
month = atoi(buffer);
printf("enter day (dd): ");
gets(buffer);
day = atoi(buffer);
printf("enter hour (hh): ");
gets(buffer);
hour = atoi(buffer);
printf("enter minute (mm): ");
gets(buffer);
minute = atoi(buffer);
printf("enter second (ss): ");
gets(buffer);
second = atoi(buffer);
/* convert date and time to bcd and update clock */
outportb(0x249,intbcd(year));
outportb(0x247,intbcd(month));
outportb(0x246,intbcd(day));
outportb(0x244,intbcd(hour));
outportb(0x243,intbcd(minute));
outportb(0x242,intbcd(second));
}
/* intbcd converts integer to binary coded decimal byte */
char intbcd(intg)
int intg;
{
int high,low;
high = intg / 10;
low = intg % 10;
return(high * 16 + low);
}